import pygame
import time

pygame.init()
screen = pygame.display.set_mode((400, 300))

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

    # 设置背景色
    screen.fill((255, 255, 255))

    # 绘制方块
    pygame.draw.rect(screen, (0, 0, 255), (100, 100, 50, 50))
    # 更新屏幕
    pygame.display.flip()
    pygame.draw.rect(screen, (255, 0, 255), (100, 100, 50, 50))
    # 更新屏幕
    pygame.display.flip()

    # 等待一段时间
    # time.sleep(10)
